package com.digitalchina.lxnsy.viewholder;

import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.PestVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2017/4/5 16:08
 * 修改备注：
 * ================================================
 */
public class SearchPestHolder extends BaseViewHolder<PestVO> {

    private SimpleDraweeView sdvImage;
    private TextView tvName;
    private TextView tvType;
    private TextView tvContent;

    public SearchPestHolder(ViewGroup parent) {
        super(parent, R.layout.item_pest_search_list);
        sdvImage = $(R.id.item_pest_sdv);
        tvName = $(R.id.item_pest_tv_name);
        tvType = $(R.id.item_pest_tv_type);
        tvContent = $(R.id.item_pest_tv_content);
    }

    @Override
    public void setData(PestVO data) {
        super.setData(data);


        FrescoUtil.showImageSmall(StringUtil.removeCharRear(data.getPicFileName(), "."), sdvImage);
        tvName.setText(data.getName());
        tvContent.setText(StringUtil.isStrEmpty(data.getMethod()) ? data.getDamage() : data.getMethod());

        switch (getAdapterPosition() % 3) {
            case 0:
                tvType.setText("相差无几");
                tvType.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvType.setBackgroundResource(R.drawable.shape_app_color_width_1dp_radius_2dp);
                break;
            case 1:
                tvType.setText("大体相同");
                tvType.setTextColor(getContext().getResources().getColor(R.color.colorRed));
                tvType.setBackgroundResource(R.drawable.shape_red_radius_2dp);
                break;
            case 2:
                tvType.setText("略有差异");
                tvType.setTextColor(getContext().getResources().getColor(R.color.colorOrange));
                tvType.setBackgroundResource(R.drawable.shape_orange_radius_2dp);
                break;
        }


    }

}
